home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Bowers Development / Demo AppMaker / Examples / PowerPlant / Everything / CModelessButtons.cp < prev    next >
Encoding:
Text File  |  1998-10-11  |  4.8 KB  |  219 lines  |  [TEXT/CWIE]

  1. // CModelessButtons.cp -- dialog methods
  2.  
  3. #include "CModelessButtons.h"
  4.  
  5. #include <UEnvironment.h>
  6. #include <UReanimator.h>
  7. #include <URegistrar.h>
  8. #include <LStream.h>
  9. #include <LTabGroup.h>
  10. #include <LStaticText.h>
  11. #include <LAMStaticTextImp.h>
  12. #include <LGAStaticTextImp.h>
  13. #include <CInvisibleButton.h>
  14. #include <LPushButton.h>
  15. #include <LAMPushButtonImp.h>
  16. #include <LGAPushButtonImp.h>
  17. #include <LTextGroupBox.h>
  18. #include <LAMControlViewImp.h>
  19. #include <LGATextGroupBoxImp.h>
  20. #include <LBevelButton.h>
  21. #include <LAMBevelButtonImp.h>
  22. #include <LGABevelButtonImp.h>
  23. #include <LCicnButton.h>
  24. #include <CustomControls.h>
  25. #include <LButton.h>
  26. #include <CTextUtils.h>
  27.  
  28. #include "EverythingCmds.h"
  29. #include <PP_Messages.h>
  30.  
  31.  
  32. #define PPob_ModelessButtonsID    214
  33. #define RidL_ModelessButtonsID    214
  34.  
  35. Boolean        CModelessButtons::sIsRegistered = false;
  36.  
  37. //----------
  38. CModelessButtons*        CModelessButtons::CreateModelessButtons (
  39.     LCommander*        inSuperCommander,
  40.     CommandT        inCommand)
  41. {
  42.     if (!sIsRegistered) {
  43.         RegisterClass ();
  44.     }
  45.     CModelessButtons*        dlog;
  46.     dlog = ((CModelessButtons *)LWindow::CreateWindow(PPob_ModelessButtonsID, inSuperCommander));
  47.     dlog->mCommand = inCommand;
  48.  
  49.     return dlog;
  50. }
  51.  
  52. //----------
  53. #define    RegisterClasses(AbstractClass,AMImpClass,GAImpClass)    \
  54.     RegisterClass_(AbstractClass);    \
  55.     if (useAppearance) {    \
  56.         RegisterClassID_(AMImpClass, AbstractClass::imp_class_ID);    \
  57.     } else {    \
  58.         RegisterClassID_(GAImpClass, AbstractClass::imp_class_ID);    \
  59.     }
  60.  
  61. //----------
  62. void    CModelessButtons::RegisterClass ()
  63. {
  64.     Boolean        useAppearance = UEnvironment::HasFeature (env_HasAppearance);
  65.  
  66.     RegisterClass_(CModelessButtons);
  67.  
  68.     // register the pane classes we use
  69.     RegisterClasses (LStaticText, LAMStaticTextImp, LGAStaticTextImp);
  70.     RegisterClass_(CInvisibleButton);
  71.     RegisterClasses (LPushButton, LAMPushButtonImp, LGAPushButtonImp);
  72.     RegisterClasses (LTextGroupBox, LAMControlViewImp, LGATextGroupBoxImp);
  73.     RegisterClasses (LBevelButton, LAMBevelButtonImp, LGABevelButtonImp);
  74.     RegisterClass_(LCicnButton);
  75.     RegisterClasses (CPushButton, CustomControlImp, CustomControlImp);
  76.     RegisterClass_(LButton);
  77.  
  78.     sIsRegistered = true;
  79. }
  80.  
  81. //----------
  82. CModelessButtons::CModelessButtons (
  83.     LStream*    inStream)
  84.     : LGADialog (inStream)
  85. {
  86. }
  87.  
  88. //----------
  89. CModelessButtons::~CModelessButtons()
  90. {
  91. }
  92.  
  93. //----------
  94. //    This member function gets called once the containment hierarchy that contains
  95. //    this pane has been built. It gives us a chance to get data members for
  96. //    interesting subviews, and to do other operations now that our subviews exist.
  97. void    CModelessButtons::FinishCreateSelf()
  98. {
  99.     LGADialog::FinishCreateSelf();
  100.  
  101.     mInvisibleButton = (CInvisibleButton*) FindPaneByID ('Inve');
  102.  
  103.     mStandardButton = (LPushButton*) FindPaneByID ('Stad');
  104.  
  105.     mDefaultButton = (LPushButton*) FindPaneByID ('Deft');
  106.  
  107.     mButtonButton = (LBevelButton*) FindPaneByID ('Butn');
  108.  
  109.     mNextButton = (LBevelButton*) FindPaneByID ('Next');
  110.  
  111.     mNext2Button = (LBevelButton*) FindPaneByID ('Nex2');
  112.  
  113.     mRightButton = (LCicnButton*) FindPaneByID ('Rigt');
  114.  
  115.     mLightButton = (CPushButton*) FindPaneByID ('Ligt');
  116.  
  117.     mRight2Button = (LButton*) FindPaneByID ('Rig2');
  118.  
  119.     mButton2Button = (CPushButton*) FindPaneByID ('But2');
  120.  
  121.     mRight3Button = (LButton*) FindPaneByID ('Rig3');
  122.  
  123.     mRect3DButton = (CPushButton*) FindPaneByID ('RecD');
  124.  
  125.     mLeftIconButton = (LPushButton*) FindPaneByID ('Lefn');
  126.  
  127.     mRightIconButton = (LPushButton*) FindPaneByID ('Rign');
  128.  
  129.     mTitledPICTButton = (CPushButton*) FindPaneByID ('TitT');
  130.  
  131.  
  132.     UReanimator::LinkListenerToControls(this, this, RidL_ModelessButtonsID);
  133.         // the purpose is to "connect" self to whatever controls
  134.         // that we want to "listen" to
  135.  
  136. // any additional initialization for your dialog:
  137.  
  138. }
  139.  
  140. //----------
  141. void    CModelessButtons::DataChanged (
  142.     long        inDataID)
  143. {
  144.     StopListening ();
  145.  
  146.  
  147.     StartListening ();
  148. }
  149.  
  150. //----------
  151. void    CModelessButtons::ListenToMessage (
  152.     MessageT    inMessage,
  153.     void        *ioParam)
  154. {
  155.     switch (inMessage) {
  156.     case msg_OK:
  157.             GetSuperCommander()->ProcessCommand(-mCommand, this);
  158.         break;
  159.  
  160.     case msg_Cancel:
  161.             DoClose();
  162.         break;
  163.  
  164.  
  165.     default:
  166.           ; // do something
  167.         break;
  168.     }
  169. }
  170.  
  171. //----------
  172. Boolean        CModelessButtons::ObeyCommand (
  173.     CommandT    inCommand,
  174.     void*        ioParam)
  175. {
  176.     Boolean        cmdHandled = true;
  177.  
  178.     if (inCommand < 0) {
  179.         // modal dialog has finished
  180.  
  181.         switch (-inCommand) {
  182.         }
  183.  
  184.     } else {
  185.         switch (inCommand) {
  186.  
  187.         default:
  188.                 cmdHandled = LGADialog::ObeyCommand(inCommand, ioParam);
  189.             break;
  190.         }
  191.     }
  192.  
  193.     return cmdHandled;
  194. }
  195.  
  196. //----------
  197. void    CModelessButtons::FindCommandStatus (
  198.     CommandT    inCommand,
  199.     Boolean        &outEnabled,
  200.     Boolean        &outUsesMark,
  201.     Char16        &outMark,
  202.     Str255        outName)
  203. {
  204.     outUsesMark = false;
  205.  
  206.     switch (inCommand) {
  207.  
  208.     // +++ Add cases here for the commands you handle
  209.  
  210.     default:
  211.             LGADialog::FindCommandStatus(inCommand, outEnabled,
  212.                                             outUsesMark, outMark, outName);
  213.         break;
  214.     }
  215. }
  216.  
  217. // following functions will be obsoleted
  218. // retained only for backwards compatibility
  219.